package com.greenyoung.pwiki.markdown.mapper;

import java.util.List;

import com.greenyoung.pwiki.markdown.entity.Markdown;
import com.greenyoung.pwiki.markdown.entity.MarkdownExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface MarkdownMapper {
    @SelectProvider(type=MarkdownSqlProvider.class, method="countByExample")
    long countByExample(MarkdownExample example);

    @DeleteProvider(type=MarkdownSqlProvider.class, method="deleteByExample")
    int deleteByExample(MarkdownExample example);

    @Delete({
        "delete from markdown",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into markdown (id, name, ",
        "path, title, author, ",
        "is_original, original_url, ",
        "create_time, last_modified)",
        "values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, ",
        "#{path,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{author,jdbcType=VARCHAR}, ",
        "#{isOriginal,jdbcType=TINYINT}, #{originalUrl,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{lastModified,jdbcType=TIMESTAMP})"
    })
    int insert(Markdown record);

    @InsertProvider(type=MarkdownSqlProvider.class, method="insertSelective")
    int insertSelective(Markdown record);

    @Select({
            "select",
            "id, name, path, title, author, is_original, original_url, create_time, last_modified",
            "from markdown"
            })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="path", property="path", jdbcType=JdbcType.VARCHAR),
            @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
            @Result(column="author", property="author", jdbcType=JdbcType.VARCHAR),
            @Result(column="is_original", property="isOriginal", jdbcType=JdbcType.TINYINT),
            @Result(column="original_url", property="originalUrl", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="last_modified", property="lastModified", jdbcType=JdbcType.TIMESTAMP)
    })
    List<Markdown> selectAll();

    @SelectProvider(type=MarkdownSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="path", property="path", jdbcType=JdbcType.VARCHAR),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="author", property="author", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_original", property="isOriginal", jdbcType=JdbcType.TINYINT),
        @Result(column="original_url", property="originalUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="last_modified", property="lastModified", jdbcType=JdbcType.TIMESTAMP)
    })
    List<Markdown> selectByExample(MarkdownExample example);

    @Select({
        "select",
        "id, name, path, title, author, is_original, original_url, create_time, last_modified",
        "from markdown",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="path", property="path", jdbcType=JdbcType.VARCHAR),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="author", property="author", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_original", property="isOriginal", jdbcType=JdbcType.TINYINT),
        @Result(column="original_url", property="originalUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="last_modified", property="lastModified", jdbcType=JdbcType.TIMESTAMP)
    })
    Markdown selectByPrimaryKey(Long id);

    @UpdateProvider(type=MarkdownSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Markdown record, @Param("example") MarkdownExample example);

    @UpdateProvider(type=MarkdownSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Markdown record, @Param("example") MarkdownExample example);

    @UpdateProvider(type=MarkdownSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Markdown record);

    @Update({
        "update markdown",
        "set name = #{name,jdbcType=VARCHAR},",
          "path = #{path,jdbcType=VARCHAR},",
          "title = #{title,jdbcType=VARCHAR},",
          "author = #{author,jdbcType=VARCHAR},",
          "is_original = #{isOriginal,jdbcType=TINYINT},",
          "original_url = #{originalUrl,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "last_modified = #{lastModified,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Markdown record);
}